<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>javascript 阶段</title>
    <style>
        body {
            font-size: 30px;
        }
        p , h3 {
            padding: 0;
            margin: 0;
        }
    </style>
</head>
<body>
    <h3>页面(3)</h3>
    <button>点击删除颜色</button>
    <script>

        // 获取cookie数据
        var str = document.cookie;
        console.log(str);

        // 获取标签
        var btn = document.querySelector("button");

        // 绑定事件
        btn.onclick = function(){
            // 删除cookie
            // 把name设置为空,把有效时间设置为过去的时间
            document.cookie = "color=; expires="+(new Date("1970/01/01"));
            // 打印cookie
            console.log(document.cookie);
        }
    </script>
</body>
</html>